#include "LockGuard.hpp"
#include "Log.hpp"
#include "Thread.hpp"
#include "Task.hpp"
#include "ThreadPool.hpp"
#include <memory>

using namespace std;

int main()
{
    // unique_ptr< ThreadPool<Task> > tp (new ThreadPool<Task>());
    // srand((uint64_t)time(nullptr));
    // tp->Start();

    sleep(10);
    ThreadPool<Task>::GetInstance()->Start();
    srand((uint64_t)time(nullptr));

    while(true)
    {
        int x = rand() % 100 + 1;
        usleep(rand() % 123);
        int y = rand() % 200;
        // int y = 0;
        usleep(rand() % 123);
        char oper = opers[rand() % opers.size()];

        Task t(x, y, oper);
        t.Enable(ok);
        //cout << "make done ... : " << t.PrintTask() << endl;
        ThreadPool<Task>::GetInstance()->Push(t);
        sleep(1);
    }

    ThreadPool<Task>::GetInstance()->Wait();
    return 0;
}